// ManageGatewayDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ManageGatewayDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CManageGatewayDlg dialog


CManageGatewayDlg::CManageGatewayDlg(CWnd* pParent /*=NULL*/)
	: CDialogResize(CManageGatewayDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CManageGatewayDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CManageGatewayDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogResize::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CManageGatewayDlg)
	DDX_Control(pDX, IDC_STC_RADIUSPORT_CONTAINNER, m_cstcRadiusPortContainer);
	DDX_Control(pDX, IDC_STC_ACCESSIP_CONTAINER, m_cstcAccessIpContainer);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CManageGatewayDlg, CDialogResize)
	//{{AFX_MSG_MAP(CManageGatewayDlg)
	ON_WM_SIZE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CManageGatewayDlg message handlers

void CManageGatewayDlg::OnSize(UINT nType, int cx, int cy) 
{
	CDialogResize::OnSize(nType, cx, cy);

	if (FALSE == ::IsWindow( m_cstcAccessIpContainer.GetSafeHwnd() ))
		return;

	CRect rectAccessIpContainer;
		m_cstcAccessIpContainer.GetWindowRect( &rectAccessIpContainer );

		CRect rectCoordiate= rectAccessIpContainer;
		const int iXBorder= rectCoordiate.left;
	const int iWidthChanged= cx - iXBorder * 2 - rectCoordiate.Width();
		const int iYBorder= rectCoordiate.top;
	const int iHeightChanged= cy - iYBorder * 2 - rectCoordiate.Height();
	if ((0 == iWidthChanged) && (0 == iHeightChanged))
		return;

	CWnd *pWnd= GetDlgItem(IDC_STC_SEPARATOR);
	CRect rectWnd;
		pWnd->GetWindowRect( &rectWnd );
		rectWnd.right += iWidthChanged;
	pWnd->MoveWindow( &rectWnd );
	CRect rectRadiusPortContainer;
		m_cstcRadiusPortContainer.GetWindowRect( &rectRadiusPortContainer );
		rectRadiusPortContainer.right += iWidthChanged;
	m_cstcRadiusPortContainer.MoveWindow( &rectRadiusPortContainer, FALSE );
	m_dlgRadiusPort.MoveWindow( &rectRadiusPortContainer, TRUE );

		rectAccessIpContainer.right += iWidthChanged;
		rectAccessIpContainer.bottom += iHeightChanged;
	m_cstcAccessIpContainer.MoveWindow( &rectAccessIpContainer, FALSE );
	m_dlgAccessIP.MoveWindow( &rectAccessIpContainer, TRUE );
}

BOOL CManageGatewayDlg::OnInitDialog() 
{
	CDialogResize::OnInitDialog();
	
VERIFY(TRUE ==
	m_dlgAccessIP.Create( IDD_GW_ACCESS_IP, &m_cstcAccessIpContainer )	);
VERIFY(TRUE ==
	m_dlgRadiusPort.Create( IDD_GW_RADIUS_PORT, &m_cstcRadiusPortContainer )	);

VERIFY(TRUE ==
	m_dlgAccessIP.ShowWindow( SW_SHOW )	);
VERIFY(TRUE ==
	m_dlgRadiusPort.ShowWindow( SW_SHOW )	);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
